<template>
  <div class="edit">
    <van-nav-bar
      fixed
      title="收货地址"
      left-arrow
      @click-left="$router.go(-1)"
    />
    <div style="">
      <van-address-edit
        :area-list="areaList"
        show-postal
        show-delete
        show-set-default
        show-search-result
        :search-result="searchResult"
        :area-columns-placeholder="['请选择', '请选择', '请选择']"
        @save="onSave"
        @delete="onDelete"
        @change-detail="onChangeDetail"
        :address-info="addressInfo"
      />
    </div>
  </div>
</template>

<script>
  import { areaList } from '@vant/area-data';
  export default {
    data() {
      return {
        areaList,
        searchResult: [],
        addressInfo: {},
        addressList:[]
      };
    },
    mounted(){
    },
    methods: {
      //保存
      onSave(content) {
        console.info(content);
      },
      onDelete() {
        if(this.addressInfo.id){
          //删除
        }
        this.addressInfo = {};
      },
      //获取编辑的地址
      getEditAddress(id){
        // if (addressList) {
        //   addressList.forEach(item=>{
        //     if(item.id == id){
        //       this.addressInfo = item;
        //     }
        //   })
        // }
      },
      onChangeDetail(val) {
        if (val) {
          this.searchResult = [
            {
              name: '黄龙万科中心',
              address: '杭州市西湖区',
            },
          ];
        } else {
          this.searchResult = [];
        }
      },
    },
  };
</script>

<style lang="less" scoped>
.edit{
  margin-top: 50px;
}
</style>
